package jdbcForMe.mySetting;

import jdbcForMe.setting.ItemSetting;

public class MyItemSetting<T> implements jdbcForMe.setting.ItemSetting {
    private T id;
    private String name;

    public MyItemSetting() {
    }

    public MyItemSetting(T id, String name) {
        this.id = id;
        this.name = name;
    }

    public T getId() {
        return id;
    }

    public void setId(T id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取主键
     *
     * @return 返回主键对象
     */
    public T getPrimaryKey() {
        return getId();
    }

    /**
     * 对比两个对象是否为同一个
     *
     * @param obj 需要对比的对象
     * @return 如果为同一个则返回true，否则返回false
     */
    @Override
    public boolean compareToSom(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof ItemSetting) {
            if (this.getPrimaryKey() == ((ItemSetting) obj).getPrimaryKey()) return true;
            return false;

        }
        return false;
    }

    @Override
    public String toString() {
        return "MyItemSetting{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}
